#!/usr/bin/python
# vi: et sw=2
#
# Author: Harry Karvonen <harry.karvonen@gmail.com>
#

from lib_pulseaudio import *

from PulseClient import PulseClient
from PulseVolume import PulseVolume

class PulseSink:
  def __init__(self):
    pass

class PulseSinkInputInfo:
  def __init__(self, pa_sink_input_info):
    self.index           = pa_sink_input_info.index
    self.name            = pa_sink_input_info.name
    self.owner_module    = pa_sink_input_info.owner_module
    self.client_id       = pa_sink_input_info.client
    self.sink            = pa_sink_input_info.sink
    self.sample_spec     = pa_sink_input_info.sample_spec
    self.channel_map     = pa_sink_input_info.channel_map
    self.volume          = PulseVolume().fromCtypes(pa_sink_input_info.volume)
    self.buffer_usec     = pa_sink_input_info.buffer_usec
    self.sink_usec       = pa_sink_input_info.sink_usec
    self.resample_method = pa_sink_input_info.resample_method
    self.driver          = pa_sink_input_info.driver
    self.mute            = pa_sink_input_info.mute
    #self.proplist        = pa_sink_input_info.proplist

    self.client          = None

    return

  def setClient(self, c):
    self.client = c

  def printDebug(self):
    print "PulseSinkInputInfo"
    print "self.index:", self.index
    print "self.name:", self.name
    print "self.owner_module:", self.owner_module
    print "self.client_id:", self.client_id
    print "self.client:", self.client
    print "self.sink:", self.sink
    print "self.sample_spec:", self.sample_spec
    print "self.channel_map:", self.channel_map
    print "self.volume:", self.volume
    print "self.buffer_usec:", self.buffer_usec
    print "self.sink_usec:", self.sink_usec
    print "self.resample_method:", self.resample_method
    print "self.driver:", self.driver
    print "self.mute:", self.mute
    #print "self.proplist:", self.proplist

  def __str__(self):
    if self.client:
      return "ID: " + str(self.index) + ", Name: \"" + \
             self.name + "\", mute: " + str(self.mute) + ", " + str(self.client)
    return "ID: " + str(self.index) + ", Name: \"" + \
           self.name + "\", mute: " + str(self.mute)
